 import time


def bubble_sort(a):
  t_start = time.time()
  n = len(a)
  for i in range(n - 1):
    for j in range(0, n - i - 1):
      if a[j] > a[j + 1]:
        a[j], a[j + 1] = a[j + 1], a[j]
  t_finish = time.time()
  return round((t_finish - t_start) * 1000)


def read2list(filename):
  file = open(filename, 'r')
  data = file.readlines()
  return data


m1 = bubble_sort(read2list("m1_sorted.txt"))
m2 = bubble_sort(read2list("m2_reverse.txt"))
m3 = bubble_sort(read2list("m3_shuffle.txt"))
print("m1_sorted", m1, "milliseconds")
print("m2_reverse", m2, "milliseconds")
print("m3_shuffle", m3, "milliseconds")
